package com.ads.proplan.activity;

import android.app.Activity;
import android.widget.TextView;

import com.ads.proplan.R;
import com.ads.proplan.control.StatisticControl;
import com.googlecode.androidannotations.annotations.EActivity;
import com.googlecode.androidannotations.annotations.UiThread;
import com.googlecode.androidannotations.annotations.ViewById;

@EActivity(R.layout.activity_statistics)
public class StatisticsActivity extends Activity {

	private StatisticControl control;
	
	@ViewById(R.id.statistics_text_result_respondidas)
	TextView respondidasTextView;
	
	@ViewById(R.id.statistics_text_result_acerto)
	TextView acertosTextView;
	
	@ViewById(R.id.statistics_text_result_erros)
	TextView errosTextView;
	
	@ViewById(R.id.statistics_text_result_aproveitamento)
	TextView aproveitamentoTextView;
	
	@ViewById(R.id.statistics_text_result_pontos)
	TextView pontosTextView;
	
	@ViewById(R.id.statistics_text_result_serie)
	TextView serieTextView;

	@ViewById(R.id.statistics_text_result_rapida)
	TextView rapidaTextView;
	
	@ViewById(R.id.statistics_text_result_media)
	TextView mediaTextView;
		
	@Override
	protected void onStart() {
		super.onStart();
		getControl();
		setElementos();
	}
	
	@Override
	protected void onStop() {
		super.onStop();
		control.finalizeControl();
	}
	
	@Override
	public void onBackPressed() {
		super.onBackPressed();
		control.finalizeControl();
	}

	@UiThread
	public void getControl() {
		control = StatisticControl.getInstance();
		control.initialControl(this);
	}

	@UiThread
	public void setElementos() {
		respondidasTextView.setText(""+control.getRespondidas());
		acertosTextView.setText(""+control.getAcertos());
		errosTextView.setText(""+control.getErros());
		aproveitamentoTextView.setText(""+control.getAproveitamento()+"%");
		pontosTextView.setText(""+control.getPontos()+"p");
		serieTextView.setText(""+control.getSerie());
		rapidaTextView.setText(""+control.getRapida()+"s");
		mediaTextView.setText(""+control.getMedia()+"s");

	}
	
	
}
